﻿package cz.dadul.adventure.asset 
{
	/**
	 * ...
	 * @author Dadul
	 */
	import flash.display.*;
	import flash.events.*;
	 
	public class TimelineScriptSet
	{
		private var _timelineScripts: Array;
		private var _mc: MovieClip;
		
		
		public function TimelineScriptSet(targetMovieClip: MovieClip) 
		{
			_timelineScripts = new Array(); 			
			_mc = targetMovieClip;
		}
		
		public function addStopScript(componentName: String, frame: String):void {
			var fn: Function = function(mc:MovieClip):void {
				mc.dispatchEvent(new Event(frame + "stop"));
			}
			
			addScript(componentName, frame, fn);
		}
		
		public function addScript(componentName: String, frame: String, fn: Function):void {			
			if (_timelineScripts[componentName] == null) {
				// Initialize
				 _timelineScripts[componentName] = new Vector.<TimelineScript>;		
			}
			var script:TimelineScript = new TimelineScript(_mc, frame, fn);			
			// Add timeline script
			_timelineScripts[componentName].add(script);			
		}
		
		
	}

}